package com.stars.empoly.activity

import android.os.Bundle
import android.view.View
import com.stars.empoly.adapter.CouponAdapter
import com.stars.empoly.base.MBActivity
import com.stars.empoly.databinding.ActivityCouponBinding
import com.stars.empoly.vmodel.CouponVModel

/**
 *on 2022/9/24
 */
class CouponActivity: MBActivity<CouponVModel, ActivityCouponBinding>() {


    override fun init(savedInstanceState: Bundle?) {
        super.init(savedInstanceState)
        var type=intent.extras?.getString("type","-1")
        vm.getInfo()
        vm.list.observe(this){
            if(null==it|| it.isEmpty()){
                binding.listEmpty.visibility=View.VISIBLE
            }else{
                binding.listEmpty.visibility=View.GONE
                //设置数据
                var adapter= CouponAdapter(type)
                binding.recyclerView.adapter=adapter
                adapter.addData(it)


            }
        }

    }
    override fun vmClass(): Class<CouponVModel> {
        return CouponVModel::class.java
    }
    override fun binding(): ActivityCouponBinding {
        return ActivityCouponBinding.inflate(layoutInflater)
    }

    override fun title(): String? {
        return "优惠卷"
    }
}
